package targaman.moltenwow.autovoter.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import targaman.moltenwow.autovoter.lang.Constants;
import targaman.moltenwow.autovoter.services.MoltenWoWLogin;
import targaman.moltenwow.autovoter.services.MoltenWoWVoter;
import targaman.moltenwow.autovoter.services.VerifyInternetConnectivity;
import targaman.moltenwow.autovoter.services.VerifyMoltenConnectivity;

import java.net.HttpURLConnection;

/**
 * Created by Jonathan on 26/12/2014.
 */
@Controller(value = Constants.CONNECTIVITY_CONTROLLER)
public class ConnectivityController {



    @Autowired
    @Qualifier(Constants.VERIFY_INTERNET_CONNETIVITY_SERVICE)
    private VerifyInternetConnectivity verifyInternetConnectivity;

    @Autowired
    @Qualifier(Constants.VERIFY_MOLTEN_CONNETIVITY_SERVICE)
    private VerifyMoltenConnectivity verifyMoltenConnectivity;



    @Autowired
    @Qualifier(Constants.MOLTEN_WOW_LOGIN_SERVICE)
    private MoltenWoWLogin moltenWoWLogin;


    @Autowired
    @Qualifier(Constants.MOLTEN_WOW_VOTER)
    private MoltenWoWVoter moltenWoWVoter;


    public boolean verifyInternetConnectivity(){
        return verifyInternetConnectivity.isConnected();
    }
    public boolean verifyMoltenConnectivity(){
        return verifyMoltenConnectivity.canConnect();
    }
    public boolean attemptLogin(String username, String password) { return moltenWoWLogin.attemptLogin(username, password);}
    public boolean checkLoginStatus() { return moltenWoWLogin.checkLoginStatus();}

    public boolean vote(HttpURLConnection conn, int voteId) { return moltenWoWVoter.vote(conn, voteId);}
    public boolean checkIfVoted(HttpURLConnection conn, int voteId) { return moltenWoWVoter.checkIfVoted(conn,voteId);}

    public VerifyInternetConnectivity getVerifyInternetConnectivity() {
        return verifyInternetConnectivity;
    }

    public void setVerifyInternetConnectivity(VerifyInternetConnectivity verifyInternetConnectivity) {
        this.verifyInternetConnectivity = verifyInternetConnectivity;
    }

    public VerifyMoltenConnectivity getVerifyMoltenConnectivity() {
        return verifyMoltenConnectivity;
    }

    public void setVerifyMoltenConnectivity(VerifyMoltenConnectivity verifyMoltenConnectivity) {
        this.verifyMoltenConnectivity = verifyMoltenConnectivity;
    }

    public MoltenWoWLogin getMoltenWoWLogin() {
        return moltenWoWLogin;
    }

    public void setMoltenWoWLogin(MoltenWoWLogin moltenWoWLogin) {
        this.moltenWoWLogin = moltenWoWLogin;
    }

    public MoltenWoWVoter getMoltenWoWVoter() {
        return moltenWoWVoter;
    }

    public void setMoltenWoWVoter(MoltenWoWVoter moltenWoWVoter) {
        this.moltenWoWVoter = moltenWoWVoter;
    }

}
